"""
=================================================
@Author: Zhenzhou Liu
@Date: 2025-01-09
@Description：
==================================================
"""
import math


class MinStack:

    def __init__(self):
        self.data = []
        self.min_stack = [math.inf]

    def push(self, val: int) -> None:
        self.data.append(val)
        self.min_stack.append(min(val, self.min_stack[-1]))

    def pop(self) -> None:
        self.min_stack.pop()
        self.data.pop()

    def top(self) -> int:
        return self.data[-1]

    def getMin(self) -> int:
        return self.min_stack[-1]